package com.lagou.springbootstudy.controller;

import com.alibaba.fastjson.JSONObject;
import com.lagou.springbootstudy.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserController {

    @Autowired
    private ArticleService articleService;

    @RequestMapping("/test")
    @ResponseBody
    public String test() {

        return JSONObject.toJSONString(articleService.list());
    }


    @RequestMapping("/index")
    public String index(Model model) {
        model.addAttribute("list", articleService.list());
        return "index";
    }


}
